package com.easyCode.mysql.sqlExec;

import com.easyCode.sqlExecer.SqlExec;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.jdbc.core.JdbcTemplate;


/**
 * sql命令执行器
 * @author 大忽悠
 * @create 2022/12/1 10:08
 */
@RequiredArgsConstructor
@Data
public class MysqlSqlExecImpl implements SqlExec {
   private final JdbcTemplate jdbcTemplate;

   /**
    * 执行sql语句
    */
   @Override
   public void exec(String[] sql){
      if(ObjectUtils.isEmpty(sql)){
         return;
      }
      jdbcTemplate.batchUpdate(sql);
   }
}
